// pkgA/expert/expert_reply/expert_reply.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id:'',
        userName:'',
        diseaseImg:'',
        description:'',
        gmtCreate:'',
        answer:'',
    },

    bind_answer(e){
        // console.log(e.detail.value)
        this.setData({
            answer:e.detail.value
        })
    },

    reply(){
        console.log(this.data.answer)
        wx.request({
          url: `http://120.77.156.205:8808/wx/disease/answer/${this.data.id}`,
          method:'POST',
          data:{
            answer:this.data.answer
          },
          success:(res)=>{
              console.log(res)
            if(res.data.code==0){
                wx.showToast({
                  title: '回复成功',
                  icon:'success'
                })
                wx.reLaunch({
                  url: `/pages/systems/systems?curIndex=1`,
                })
            }
          }
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        console.log(options.id)
        this.setData({
            id:options.id
        })
        wx.request({
          url: `http://120.77.156.205:8808/wx/disease/getDiseaseVo/${options.id}`,
          method:'GET',
          success:(res)=>{
            if(res.data.code == 0){
                let diseaseVo = res.data.data.diseaseVo;
                this.setData({
                    userName:diseaseVo.userName,
                    diseaseImg:diseaseVo.disease.diseaseImg,
                    description:diseaseVo.disease.description,
                    gmtCreate:diseaseVo.disease.gmtCreate
                })
            }else{
                wx.showToast({
                    title: '服务器异常',
                    icon:'error'
                  })
            }
          },
          fail:(err)=>{
              wx.showToast({
                title: '服务器异常',
                icon:'error'
              })
          }
        })
    },
})